import { useEffect, useState } from 'react'
import reactLogo from './assets/react.svg'
import viteLogo from '/vite.svg'
import './App.css'
import { ConfigProvider } from 'zarm'
import { Router, Routes,Route, useLocation } from 'react-router-dom'
import zhCN from 'zarm/lib/config-provider/locale/zh_CN'
import 'zarm/dist/zarm.css'
import routes from '@/router'
import NavBar from './components/NavBar'

function App() {
  const [showNav,setShownav]=useState(false)
  const path=['/','/data','/user']
  const location=useLocation()
  const {pathname}=location
  useEffect(()=>{
    setShownav(path.includes(pathname))
  },[pathname])
  return (
    <>
<ConfigProvider  primaryColor={'#007fff'}  locale={zhCN}>
    {/* 在 App.jsx 引入路由配置，实现切换浏览器路径，显示相应的组件 */}
     <Routes>
      {routes.map(item=> <Route exact key={item.path} path={item.path} element={<item.component />} />)}
     </Routes>
     </ConfigProvider>
     <NavBar showNav={showNav}/>
    </>
  )
}

export default App
